//
// Created by redcat1 on 01.05.2024.
//

#if defined(TESTING_MODE)
  #include "test_vector_.h" // for testing
#endif

#include "vector_.h"
#include "figures.h"
#include "data_generator.h"
#include <iostream>

//
template<class T, int BufferSize>
static std::ostream& operator<<(std::ostream& os, const Vector<T, BufferSize>& v)
{
  os << ToString(v);
  return os;
}

//
Figure* GetRandomFigure()
{
  switch (GetRandomInt(1, 3))
  {
    case 1:
      return new Rectangle(GetRandomRectangle());
    case 2:
      return new Circle(GetRandomCircle());
    case 3:
      return new RightTriangle(GetRandomRightTriangle());
    default:
      return nullptr;
  }
}

//
void RunMainMode()
{
  Vector<Figure*> v(100, nullptr);
  for (int i = 0; i < 100; ++i)
  {
    v[i] = GetRandomFigure();
  }

  for (int i = 0; i < 100; ++i)
  {
    std::cout << "\nindex: " << i << std::endl;
    std::cout << "type: " << v[i]->Type() << std::endl;
    std::cout << "area: " << v[i]->Area() << std::endl;
    std::cout << "perimeter: " << v[i]->Perimeter() << std::endl;
  }

  for (int i = 0; i < 100; ++i)
  {
    delete v[i];
  }
  std::cout << "Done!" << std::endl;
}

//
int main()
{
#if defined(TESTING_MODE)
  RunVectorTests();
#else
  RunMainMode();
#endif

  return 0;
}